<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
<title>{$site_name}</title>
<!-- CSS -->
<link rel="stylesheet" href="{url:#css/materialize.min.css}" />
<link rel="stylesheet" href="{url:#css/me.css}" />
<link rel="stylesheet" href="{url:#css/iconfont.css}" />

<style type="text/css">
/**去除绿色下划线 - 开始*/
input::-webkit-input-placeholder 
{
    color: #7e7e7e;
    text-indent: 5px;
}
input:not([type]),input[type=text],input[type=password],input[type=email],input[type=url],input[type=time],input[type=date],input[type=datetime-local],input[type=tel],input[type=number],input[type=search],textarea.materialize-textarea{background-color:transparent;border:none;border-radius:0;outline:none;height:1.5em;width:100%;font-size:1rem;margin:0;padding:0;box-shadow:none;}
input:not([type]):focus:not([readonly]),input[type=text]:focus:not([readonly]),input[type=password]:focus:not([readonly]),input[type=email]:focus:not([readonly]),input[type=url]:focus:not([readonly]),input[type=time]:focus:not([readonly]),input[type=date]:focus:not([readonly]),input[type=datetime-local]:focus:not([readonly]),input[type=tel]:focus:not([readonly]),input[type=number]:focus:not([readonly]),input[type=search]:focus:not([readonly]),textarea.materialize-textarea:focus:not([readonly]){border-bottom:none;box-shadow:none}
/**去除绿色下划线 - 结束*/
</style>
<!-- JS -->
<script src="{url:#js/jquery-1.11.3.min.js}"></script>
<script src="{url:#js/materialize.min.js}"></script>
<script src="{url:#js/home/register.js}"></script>
<script src="{url:#js/yang_check.js}"></script>
</head>
<body class="q-body">
<!-- TitleBar 开始 -->
<div class="navbar-fixed">
  <nav>
    <div class="nav-wrapper red accent-4 valign-wrapper">
      <ul class="left" id="nav-btn-left">
        <li><a href="{url:/mobile/user_center}"><i class="iconfont">&#xe63c;</i></a></li>
      </ul>
      <span class="title-bar-size center_align">修改密码</span>
      <ul class="right">
        <li><a  class="disabled" style="visibility:hidden"><i class="iconfont">&#xe63c;</i></a></li>
      </ul>
    </div>
  </nav>
</div>
<!-- TitleBar 结束 -->

<div class="container">
	 <div class="q-reg-box">
	    <table>
		<tr>
			<td class="q-ltitle">原密码：</td>
			<td><input type="password" name="password" id="password" placeholder="请输入原密码" style="border:1px solid #ccc;padding:10px; margin-left:-10px;"/></td>
		</tr>
        <tr>
			<td class="q-ltitle">新密码：</td>
			<td><input type="password" name="new_password" id="new_password" placeholder="请输入新密码" style="border:1px solid #ccc;padding:10px; margin-left:-10px;"/></td>
		</tr>
        <tr>
			<td class="q-ltitle">请确认：</td>
			<td><input type="password" name="sure_password" id="sure_password" placeholder="请确认新密码" style="border:1px solid #ccc;padding:10px; margin-left:-10px;"/></td>
		</tr>
		<tr>
			<td class="q-ltitle">类型：</td>
			<td>
                  <select name="password_type" id="password_type"  class="q-krap" style="border:1px solid #ccc;padding:10px; margin-left:-10px;">
                    <option value="0" selected="selected">登录密码</option>
                    <option value="1">二级密码</option>
                 </select> 
            </td>
		 </tr>
	 </table>
	 
	</div>
	<div class="center clearfix" style="margin-right:10px; margin-left:10px;margin-top:60px;">
		<input type="hidden" name="user_id" id="user_id" value="{$mobile_user['id']}"/>
		<a class="waves-effect waves-light btn-large red z-depth-0 login_btn" id="a_update">立即修改</a>
	</div>
</div>
<script>
$(function(){
	$("#a_update").click(function(){
		
		if( input_is_null_validate('password') == false )
		{
			yang_alert('原密码不能为空');
			return;
		}
		
		if( input_pattern_validate('password','pwd') == false )
		{
			yang_alert('原密码不合法');
			return;
		}

		if( input_is_null_validate('new_password') == false )
		{
			yang_alert('新密码不能为空');
			return;
		}
		
		if( input_pattern_validate('new_password','pwd') == false )
		{
			yang_alert('新密码不合法');
			return;
		}

		if( input_is_null_validate('sure_password') == false )
		{
			yang_alert('确认密码不能为空');
			return;
		}
		
		if( input_pattern_validate('sure_password','pwd') == false )
		{
			yang_alert('确认密码不合法');
			return;
		}
		
		if( input_is_equal_validate('new_password', 'sure_password') == false )
		{
			yang_alert('新密码和确认密码不一致');
			return;
		}

		var password = $("#password").val();
		var new_password = $("#new_password").val();
		var sure_password = $("#sure_password").val();
		var password_type = $("#password_type").val();
		var user_id  = $("#user_id").val();

		if(password == new_password || password == sure_password)
		{
			yang_alert('新密码和原密码不能相同');
			return;
		}

		
		$.post('{url:/mobile/change_password_do}',{password:password,new_password:new_password,sure_password:sure_password,password_type:password_type,user_id:user_id},function(data){
	        if( data['status']=='success' )
		    {
	        	yang_alert('操作成功');
			    //个人中心页面
	            location.href="{url:/mobile/change_password}";
	            
	        }
	        else
		    {
	        	yang_alert(data['msg']);
	        }
	      },'json');
		
	});
});
</script>
</body>
</html>
